﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WS.EKA.Utility;

namespace WS.EKA.SyncData
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("SyncData Begining...");
            Logger.Log("SyncData Begining...");
            if (args.Length == 0)
            {
                Console.WriteLine("No paramters input!");
                Logger.Error("No paramters input!", null);
            }
            else
            {
                string target = string.Empty;
                string data = string.Empty;
                for (int i = 0; i < args.Length; i++)
                {
                    if (args[i].ToUpper() == "-DATA")
                    {
                        data = args[i + 1];
                    }
                    else if (args[i].ToUpper() == "-TARGET")
                    {
                        target = args[i + 1];
                    }
                }

                //fix include " issue
                if (args.Count() > 4)
                {
                    StringBuilder sb = new StringBuilder();
                    for (int i = 4; i < args.Count(); i++)
                    {
                        sb.Append(args[i]);
                    }
                    data = data + sb.ToString();
                }

                //IService service = ServiceFactory.CreateService(target);
                //if (service == null)
                //{
                //    Console.WriteLine("Target error!");
                //    Logger.Error("Target error!", null);
                //}
                //else
                //{
                
#if DEBUG
                SyncData.ExecuteByMSMQ(target, data);
#else
                SyncData.ExecuteByWebService(target, data);
#endif


                //}

                Console.WriteLine("SyncData End.");
                Logger.Log("SyncData End.");
            }
        }

    }
}
